/*
 * @Description:
 * @Version: 1.0
 * @Author: MapleLeaf
 * @Date: 2021-05-22 09:42:22
 * @LastEditors: MapleLeaf
 * @LastEditTime: 2021-05-22 18:17:20
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import viteCompression from "vite-plugin-compression";
import path from "path";
const resolve = (dir: string) => path.join(__dirname, dir);
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // 生产环境生成 .gz 文件
    viteCompression({
      verbose: true,
      disable: false,
      threshold: 10240,
      algorithm: "gzip",
      ext: ".gz",
    }),
  ],
  base: "./", // 打包路径
  resolve: {
    // 设置别名
    alias: {
      "@": resolve("src"),
    },
  },
  server: {
    host: "0.0.0.0",
    https: false,
    port: 4000, // 启动端口
    open: true,
    // proxy: {
    //   // 选项写法
    //   '/api': 'http://xxxx'// 代理网址
    // },
    cors: true,
  },
  build: {
    // 生产环境移除 console
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true,
      },
    },
  },
});
